package com.example.springaop.aop;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 * User:xieChao
 * Date:2023/1/8 21:46
 */
@Aspect   //当前是一个切面
@Component
public class UserAspect {
    // 前置通知
    @Before("pointcut()")
    public void doBefore(){
        System.out.println("执⾏ Before ⽅法");
    }
    // 定义切点⽅法
    @Pointcut("execution(* com.example.springaop.controller.UserController.* (..))")
    public void pointcut(){ }

    // 后置通知
//    @After("pointcut()")
//    public void doAfter(){
//        System.out.println("执⾏ After ⽅法");
//    }
}
